﻿@using Covenant.Models.Listeners
@model BridgeListener
@{
    IEnumerable<Profile> GenericProfiles = ViewBag.Profiles;
    IEnumerable<Profile> Profiles = GenericProfiles.Where(P => P.Type == ProfileType.Bridge);
    IEnumerable<ListenerType> ListenerTypes = ViewBag.ListenerTypes;
    ListenerType lt = ListenerTypes.FirstOrDefault(LT => LT.Name == "Bridge");
}

<form asp-action="CreateBridge">
    <div asp-validation-summary="All" class="text-danger"></div>
    <input asp-for="Id" value="@Model.Id" type="hidden">
    <input asp-for="GUID" value="@Model.GUID" type="hidden">
    <input asp-for="ListenerTypeId" value="@lt.Id" type="hidden">
    <input asp-for="Status" value="Active" type="hidden">
    <input asp-for="CovenantToken" value="@Model.CovenantToken" type="hidden">
    <div class="form-group">
        <label asp-for="Description"></label>
        <input asp-for="Description" value="@Model.Description" class="form-control-plaintext" readonly>
    </div>
    <div class="form-group">
        <label asp-for="Name"></label>
        <input asp-for="Name" value="@Model.Name" class="form-control">
    </div>
    <div class="form-row">
        <div class="form-group col-md-4">
            <label asp-for="BindAddress"></label>
            <input asp-for="BindAddress" value="@Model.BindAddress" class="form-control">
        </div>
        <div class="form-group col-md-4">
            <label asp-for="BindPort"></label>
            <input asp-for="BindPort" value="@Model.BindPort" class="form-control">
        </div>
    </div>
    <div class="form-row">
        <div class="form-group col-md-3">
            <label asp-for="ConnectPort"></label>
            <input asp-for="ConnectPort" value="@Model.ConnectPort" class="form-control">
        </div>
    </div>
    <div class="d-flex flex-row address-row">
        <div class="form-group col-md-4 pl-0 mt-1 mb-1">
            <label asp-for="ConnectAddresses[0]">ConnectAddress</label>
            <input asp-for="ConnectAddresses[0]" value="@Model.ConnectAddresses[0]" class="form-control address">
        </div>
    </div>
    <div class="form-group">
        <label asp-for="ProfileId">BridgeProfile</label>
        <select asp-for="ProfileId" class="form-control">
            @foreach (var item in Profiles)
            {
                <option value="@item.Id">@item.Name</option>
            }
        </select>
    </div>
    <button type="submit" class="btn btn-primary"><span data-feather="plus"></span> Create</button>
</form>